From 6d7049218a3f04cf3063067c356ea178d813601c Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 15 Dec 2016 20:27:48 +0300 Subject: [PATCH] Don't ignore errors in workspace manifest --- src/cargo/core/workspace.rs | 4 ++-- tests/workspaces.rs | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/cargo/core/workspace.rs b/src/cargo/core/workspace.rs index d0b0fdeec..c396755e8 100644 --- a/src/cargo/core/workspace.rs +++ b/src/cargo/core/workspace.rs @@ -242,8 +242,8 @@ impl<'cfg> Workspace<'cfg> { while let Some(path) = cur { let manifest = path.join("Cargo.toml"); debug!("find_root - trying {}", manifest.display()); - if let Ok(pkg) = self.packages.load(&manifest) { - match *pkg.workspace_config() { + if manifest.exists() { + match *self.packages.load(&manifest)?.workspace_config() { WorkspaceConfig::Root { .. } => { debug!("find_root - found"); return Ok(Some(manifest)) diff --git a/tests/workspaces.rs b/tests/workspaces.rs index 579dfa0db..8204e6c34 100644 --- a/tests/workspaces.rs +++ b/tests/workspaces.rs @@ -1055,3 +1055,22 @@ fn workspace_with_transitive_dev_deps() { assert_that(p.cargo("test").args(&["-p", "bar"]), execs().with_status(0)); } + +#[test] +fn error_if_parent_cargo_toml_is_invalid() { + let p = project("foo") + .file("Cargo.toml", "Totally not a TOML file") + .file("bar/Cargo.toml", r#" + [project] + name = "bar" + version = "0.1.0" + authors = [] + "#) + .file("bar/src/main.rs", "fn main() {}"); + p.build(); + + assert_that(p.cargo("build").cwd(p.root().join("bar")), + execs().with_status(101) + .with_stderr_contains("\ +[ERROR] failed to parse manifest at `[..]`")); +} -- 2.30.2